Skip to content

feat(cli): add agent markers other detectors use, verified upstream - #7425

Merged
jrusso1020 merged 3 commits into
mainfrom
agent-runtimes-lib-markers
Nov 9, 2026
Merged

jrusso1020 merged 3 commits into
mainfrom
agent-runtimes-lib-markers

Conversation

@jrusso1020

@jrusso1020 jrusso1020 commented Nov 9, 2026 •

Copy link
Copy Markdown
Collaborator

What

  • Markers from other detectors, verified upstream. I compared our rules with std-env, @vercel/detect-agent, am-i-vibing and agent-cli-detector, and kept only markers the agent itself sets on the shells it spawns:

    Agent Marker Evidence
    Auggie (auggie, new) AUGMENT_AGENT @augmentcode/auggie bundle: the shell tool is built with env: { AUGMENT_AGENT: "1" }
    Amp AMP_CURRENT_THREAD_ID @sourcegraph/amp bundle: the Bash tool and toolbox subprocesses get it
    Cursor CURSOR_CONVERSATION_ID, CURSOR_SANDBOX CLI and IDE agent-exec bundles; CURSOR_SANDBOX documented in cursor.com run-modes
    Cline CLI CLINE_WRAPPER_PATH cline/cline apps/cli/bin/cline
    Muse Code (muse, new) MUSE_RELEASE_INFO Meta's muse-launcher.sh exports it before exec
    Warp Oz (warp_oz, new) OZ_RUN_ID warpdotdev/warp crates/warp_cli/src/lib.rs. Checked after the harnesses it wraps (Claude Code, Codex, Gemini).
  • Claude Code fix. The rule now keys on CLAUDE_CODE_CHILD_SESSION (or the inherited CLAUDE_CODE_ENTRYPOINT), not CLAUDECODE. Claude Code's docs say its IDE extensions also set CLAUDECODE in their integrated terminals, so a person typing in that terminal counted as an agent: isUnattended stopped prompting them, and auth login took the agent path.

  • Package size budget: @hyperframes/cli packed budget goes from 7982002 to 8062664, the measured size. main already sat at the edge of the 1% tolerance, and these rules put the packed CLI 842 bytes past it.

  • Cleanup: fixes the stale "rules above" wording from fix(cli): let an agent's own name beat editor and host markers #7424 review, plus two citations the comment gate flags.

Why

Follow-up to #7423 / #7424.

Left out on purpose: user settings and tokens such as COPILOT_MODEL, COPILOT_ALLOW_ALL, GOOSE_PROVIDER, OPENCODE_CLIENT, JUNIE_DATA, FACTORY_ENV. Also left out:

  • markers set on a whole workspace a person also types in (CURSOR_TRACE_ID, REPLIT_SESSION, Bolt's, KILO_RUN_ID);
  • hook-only markers (DEVIN_PROJECT_DIR, DROID_PROJECT_DIR);
  • anything only seen in a compiled binary with no readable context (KIRO_SESSION_ID, ANTIGRAVITY_TRAJECTORY_ID).

Related work

Refs #7423, #7424

How

  • New rules sit with the other agent rules; warp_oz goes just before the Agent SDK rule.
  • Tests that simulated a Claude Code shell with CLAUDECODE=1 now use CLAUDE_CODE_CHILD_SESSION=1.
  • A new test pins that CLAUDECODE alone (the IDE terminal) is neither claude_code nor agent-driven.

Test plan

  • Unit tests: each new marker, Oz losing to the harness it wraps (Codex), and the Claude IDE terminal case.
  • Ran the telemetry, attendedTerminal, desktopApp, auth login, agentMode, telemetryIdentity and usage tests: 1136/1136. tsc --noEmit, comment-citations and comment-ratchet also pass.
  • Manual testing performed
  • Comments follow CONTRIBUTING.md "Comments"

— Rames

🤖 Generated with Claude Code

jrusso1020 and others added 2 commits November 9, 2026 02:47
Compared std-env, @vercel/detect-agent, am-i-vibing and agent-cli-detector
against our rules and kept only markers the agent itself sets on the
shells it spawns: Auggie AUGMENT_AGENT, Amp AMP_CURRENT_THREAD_ID, Cursor
CURSOR_CONVERSATION_ID and CURSOR_SANDBOX, Cline CLI CLINE_WRAPPER_PATH,
Muse MUSE_RELEASE_INFO, and Warp Oz OZ_RUN_ID (after the harnesses it
wraps).

Claude Code now keys on CLAUDE_CODE_CHILD_SESSION or
CLAUDE_CODE_ENTRYPOINT. Its IDE extensions also set CLAUDECODE in the
integrated terminal a person types into, so CLAUDECODE alone counted that
person as an agent: no prompts, agent-mode login.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@github-actions

github-actions Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Edit accuracy: accurate 267 (base branch 267), smooth 113 of those

The gate passes.
Smoothness is reported in the artifact, not gated. A case fails only if it fails 2 of 3 runs.

Quarantined, measured but not gated (8)

Unstable (2)

  • seqrotatenudge-none-pct-r0-root-z100: tracking 0.03, pressJump 0, drop 0, reload 3.03, render 0.04, renderKey -, undo false, teleport true / tracking 0.03, pressJump 0, drop 0, reload 0, render 0.08, renderKey -, undo true, teleport true / tracking 0.03, pressJump 0, drop 0, reload 0, render 0.08, renderKey -, undo true, teleport true
  • seqab-none-px-r0-root-z100: tracking 0.03, pressJump 0, drop 0, reload 0, render 0.03, renderKey -, undo true, teleport true / tracking 0.03, pressJump 0, drop 0, reload 0, render 0.03, renderKey -, undo true, teleport true / tracking 0.03, pressJump 0, drop 0, reload 0, render 0.03, renderKey -, undo true, teleport true

main already sat at the edge of the 1% tolerance; the new agent rules
put the packed CLI 842 bytes past it (8062664 vs 7982002 + 1%).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

@heygengenesis heygengenesis Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: APPROVE · 0 blocker · 0 important · 2 nits · head 5d2ee2e3

The Claude Code change holds up against the 2.1.319 binary and VS Code extension. The Bash tool sets CLAUDE_CODE_CHILD_SESSION along with CLAUDECODE. claude puts CLAUDE_CODE_ENTRYPOINT in its own env at startup, so every child inherits it. The extension's terminals set neither marker. Both nits are comment wording ↓

Scope, blast radius, CI
  • isUnattended: a person whose IDE terminal has only CLAUDECODE now gets prompts again. Every real Claude Code spawn still matches through CHILD_SESSION or ENTRYPOINT, including stdio MCP servers and versions before 2.1.172, so agents still get no prompts.
  • auth login: agentShellOnThisMachine only matters when stdout is not a TTY, so the CLAUDECODE change has no effect on a TTY user. The new markers send more agents without a TTY to the browser sign-in, which is the intended result.
  • desktopApp: someoneToTell short-circuits on tty, so a person at a terminal sees no change. Agents with the new markers now get the hint. Two other callers of detectAgentRuntime also change behaviour: feedback.ts (an IDE-terminal person gets the normal TTY prompt instead of the agent line) and the Studio __HF_CLI_AGENT_RUNTIME label. Both changes are correct.
  • I found no downstream enum for AgentRuntime that needs auggie, muse or warp_oz added. usage.ts detectHarness still keys on CLAUDECODE, which is fine for that command.
  • Spot checks: Cline apps/cli/bin/cline sets CLINE_WRAPPER_PATH in childEnv. Warp's local harness panes are hidden and launched off-screen, so OZ_RUN_ID does not leak into a terminal a person types in. OpenCode, which Oz also wraps, is matched before warp_oz.
  • Local runs: telemetry/*, attendedTerminal, auth login, desktopApp, telemetryIdentity and usage gave 616/616. cli.agentMode gave 518/518. I ran the suites both with and without Claude Code markers in the environment.
  • CI at 5d2ee2e3: CI, Windows render verification, regression, CodeQL and Comments are all green. The budget bump is explained in the PR body.

— Genesis

// every child (main.tsx:527). Both propagate to spawned subprocesses.
// Source: confirmed by @magi from Claude Code internal source.
// Claude Code sets CLAUDE_CODE_CHILD_SESSION on what its tools spawn, and an
// inherited CLAUDE_CODE_ENTRYPOINT (older versions). Not CLAUDECODE: its IDE

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: CLAUDE_CODE_ENTRYPOINT is not only from older versions. Current claude (2.1.319) sets it to cli/sdk-cli/mcp at startup. It is also the only Claude marker that reaches a stdio MCP server (Claude Code removes CHILD_SESSION there) and shells from versions before 2.1.172. Calling it "older versions" invites someone to delete it later, which would break detection in exactly those cases.

Suggested change
// inherited CLAUDE_CODE_ENTRYPOINT (older versions). Not CLAUDECODE: its IDE
// inherited CLAUDE_CODE_ENTRYPOINT (MCP servers, pre-2.1.172). Not CLAUDECODE: its IDE

// Source: https://github.com/warpdotdev/warp (crates/warp_cli/src/lib.rs)
{ name: "warp_oz", check: (env) => typeof env["OZ_RUN_ID"] === "string" },
// An app built on the Claude Agent SDK, running a command outside Claude
// Code's own shell tool (that path sets CLAUDECODE, caught above). The SDK

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: this comment is out of date now that the rule no longer reads CLAUDECODE.

Suggested change
// Code's own shell tool (that path sets CLAUDECODE, caught above). The SDK
// Code's own shell tool (that path sets CLAUDE_CODE_CHILD_SESSION, caught above). The SDK

@jrusso1020
jrusso1020 added this pull request to the merge queue Nov 9, 2026
Merged via the queue into main with commit 7bf6599 Nov 9, 2026
93 of 94 checks passed
@jrusso1020
jrusso1020 deleted the agent-runtimes-lib-markers branch November 9, 2026 03:48
jrusso1020 added a commit that referenced this pull request Nov 9, 2026
CLAUDE_CODE_ENTRYPOINT is set by current Claude Code versions too, and it
is the only Claude marker MCP servers inherit, so it is not an
"older versions" fallback. The Agent SDK comment still said Claude Code's
shell tool sets CLAUDECODE; the rule keys on CLAUDE_CODE_CHILD_SESSION.

Follow-up to review nits on #7425. Comments only.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
kvnloo pushed a commit to kvnloo/hyperframes that referenced this pull request Nov 9, 2026
…ygen-com#7426)

CLAUDE_CODE_ENTRYPOINT is set by current Claude Code versions too, and it
is the only Claude marker MCP servers inherit, so it is not an
"older versions" fallback. The Agent SDK comment still said Claude Code's
shell tool sets CLAUDECODE; the rule keys on CLAUDE_CODE_CHILD_SESSION.

Follow-up to review nits on heygen-com#7425. Comments only.

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant